﻿$(document).ready(function () {
    var pager = $('#dg').datagrid('getPager'); // get the pager of datagrid
    pager.pagination({ showPageList: false });

});



function updateItem(action) {
    var row = $('#dg').datagrid('getSelected');
    if (row) {
        window.location.href = action + row.Id;
    } else {
        $.messager.show({
            title: '提示',
            msg: "请选择行"
        });
    }
}


function destroyItem(action) {
    var row = $('#dg').datagrid('getSelected');
    if (row) {
        $.messager.confirm('Confirm', '你确定删除此项吗?', function(r) {
            if (r) {
                $.post(action, { id: row.Id }, function(result) {
                    if (result.success) {
                        $('#dg').datagrid('reload'); // reload the user data  
                    } else {
                        $.messager.show({
                            title: '提示',
                            msg: "删除失败！"
                        });
                    }
                }, 'json');
            }
        });
    } else {
        $.messager.show({
            title: '提示',
            msg: "请选择行"
        });
    }
}

function formatColumn(colName, value, row, index) {
    return eval("row." + colName);
}
function formatColumn1(colName, value, row, index) {
    return eval("row." + colName);
}